<?php

use think\migration\Migrator;
use think\migration\db\Column;

class UrlLogs1 extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('url_logs1',array('engine'=>'MyISAM'));
        $exists = $this->hasTable('url_logs1');
        if(!$exists){
            $table
                ->addColumn('urls_id', 'integer',array('limit' => 11,'default'=>0,'comment'=>'网址id'))
                ->addColumn('city', 'string',array('limit' =>50,'default'=>0,'comment'=>'城市'))
                ->addColumn('province', 'string',array('limit' =>50,'default'=>0,'comment'=>'省份'))
                ->addColumn('country', 'string',array('limit' =>50,'default'=>0,'comment'=>'国家'))
                ->addColumn('ip', 'integer',array('limit' => 11,'default'=>0,'comment'=>'访问IP'))
                ->addColumn('browser', 'string',array('limit' => 20,'default'=>0,'comment'=>'浏览器类型'))
                ->addColumn('is_mobile', 'integer',array('limit' => 1,'default'=>0,'comment'=>'访问环境1移动端，2pc端'))
                ->addColumn('create_time', 'integer',array('limit' => 11,'default'=>'1563845960','comment'=>'创建时间'))
                ->addIndex(array('urls_id'))
                ->create();
        }
    }
}
